package com.chenjun.core.dao.generator.mapper;

import com.chenjun.core.dao.generator.entity.SysLog;
import com.chenjun.core.dao.generator.entity.SysLogExample;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface SysLogMapper {
    @Delete({
        "delete from sys_log",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into sys_log (id, user_id, ",
        "user_name, methods, ",
        "params, url, created_time)",
        "values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, ",
        "#{userName,jdbcType=VARCHAR}, #{methods,jdbcType=VARCHAR}, ",
        "#{params,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{createdTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT replace(UUID(), '-', '')", keyProperty="id", before=true, resultType=String.class) 
    int insert(SysLog record);

    int insertSelective(SysLog record);

    List<SysLog> selectByExample(SysLogExample example);

    @Select({
        "select",
        "id, user_id, user_name, methods, params, url, created_time",
        "from sys_log",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    SysLog selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(SysLog record);

    @Update({
        "update sys_log",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "user_name = #{userName,jdbcType=VARCHAR},",
          "methods = #{methods,jdbcType=VARCHAR},",
          "params = #{params,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "created_time = #{createdTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(SysLog record);
}